package com.ruoyi.project.app.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.app.domain.AppDispatch;
import com.ruoyi.project.app.service.IAppDispatchService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 客服调度Controller
 * 
 * @author hry
 * @date 2020-10-15
 */
@RestController
@RequestMapping("/system/appDispatch")
public class AppDispatchController extends BaseController
{
    @Autowired
    private IAppDispatchService appDispatchService;

    /**
     * 查询客服调度列表
     */
    @PreAuthorize("@ss.hasPermi('system:appDispatch:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppDispatch appDispatch)
    {
        startPage();
        List<AppDispatch> list = appDispatchService.selectAppDispatchList(appDispatch);
        return getDataTable(list);
    }

    /**
     * 导出客服调度列表
     */
    @PreAuthorize("@ss.hasPermi('system:appDispatch:export')")
    @Log(title = "客服调度", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AppDispatch appDispatch)
    {
        List<AppDispatch> list = appDispatchService.selectAppDispatchList(appDispatch);
        ExcelUtil<AppDispatch> util = new ExcelUtil<AppDispatch>(AppDispatch.class);
        return util.exportExcel(list, "appDispatch");
    }

    /**
     * 获取客服调度详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:appDispatch:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(appDispatchService.selectAppDispatchById(id));
    }

    /**
     * 新增客服调度
     */
    @PreAuthorize("@ss.hasPermi('system:appDispatch:add')")
    @Log(title = "客服调度", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppDispatch appDispatch)
    {
        return toAjax(appDispatchService.insertAppDispatch(appDispatch));
    }

    /**
     * 修改客服调度
     */
    @PreAuthorize("@ss.hasPermi('system:appDispatch:edit')")
    @Log(title = "客服调度", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppDispatch appDispatch)
    {
        return toAjax(appDispatchService.updateAppDispatch(appDispatch));
    }

    /**
     * 删除客服调度
     */
    @PreAuthorize("@ss.hasPermi('system:appDispatch:remove')")
    @Log(title = "客服调度", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appDispatchService.deleteAppDispatchByIds(ids));
    }
}
